package com.nullyb.springbootshardingjdbc.enums;

public enum Databases {

    NGBMPBJ("ngbmpbj","00030001"),
    NGBMPTJ("ngbmptj","00030002"),
    NGBMPNM("ngbmpnm","00030003");

    private final String databaseName;
    private final String databaseCode;

    Databases(String databaseName,String databaseCode){
        this.databaseName = databaseName;
        this.databaseCode = databaseCode;
    }

    public String getDatabaseName() {
        return databaseName;
    }

    public String getDatabaseCode() {
        return databaseCode;
    }

    public static String getDatabaseName(String databaseCode) {
        for (Databases database: Databases.values()) {
            if(database.databaseCode.equals(databaseCode)){
                return database.databaseName;
            }
        }
        throw new RuntimeException("数据库编码（" + databaseCode+ "）异常！");
    }
}
